package com.mk.common.util;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class DemoServer
{
	public static void main(String[] args) throws IOException
	{
//		try {
//			
//		} catch(Exception e) {
//			
//		} finally {
//			
//		}
		
		
		//服务器套接字
		ServerSocket serverSocket = new ServerSocket(BasicConstants.NET_PORT);
		//监听连接
		Socket socket = serverSocket.accept();
		
		DataInputStream inputStream = new DataInputStream(socket.getInputStream());
		DataOutputStream outputStream = new DataOutputStream(socket.getOutputStream());
		
		//读取
		String detail = inputStream.readUTF();
		
		//处理
		System.out.println("客户端: "+detail);
		
		//回应
		outputStream.writeUTF("收到");
		outputStream.flush();
		
		//关闭资源
		socket.close();
		serverSocket.close();
	}
}
